package com.zwj.hmall.service;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 声明式事务Demo
 *
 * @author 张文接
 * @version 1.0
 * @createTime 2024/8/5 21:23
 */
@Service
public class DeclarativeTransactionService {
    @Resource
    private JdbcTemplate jdbcTemplate;

    @Transactional
    public void demo1() {
        jdbcTemplate.update("update tb_user set money = money + ? where account = ?", 1, "mike");
        int i = 1 / 0;
    }
}
